<%@page import="ll.sms.util.*,java.net.*"%><%@ page language="java" import="org.apache.commons.lang.*,java.util.*,ll.sms.web.*,ll.sms.pojo.*,ll.sms.web.*"  pageEncoding="UTF-8"%>

<%
try{
		SmsAdmin smsAdmin = new SmsAdmin();
		RequestUtils.populate(smsAdmin,request);
		smsAdmin.setArank(SmsConstant.PROXY_TYPE);//代理类型
		String newapwd = request.getParameter("pwd");
		String pass_cfrm = request.getParameter("npwd");
		String userid = request.getParameter("userid");
		String flag = request.getParameter("flag");

		//修改用户密码
	   if("changepassword".equals(flag)){
	    if(StringUtils.isBlank(userid)){
	    out.print( "{success:false,errors:{msg:'所修改用户ID为空'}}");
	    return;
	    }
			if (!StringUtils.isBlank(newapwd)&& newapwd.equals(pass_cfrm)) {
				out.print(WebBusinessImpl.getInstance().updateAdminPassword(userid,newapwd));
				return;
			}else{
					 out.print( "{success:false,errors:{msg:'两次密码不匹配'}}");
			}
			return;

		}

		String def = smsAdmin.getAdefaultchannel();
		if(def == null || def.equals("") || "itemselector=".equals(smsAdmin.getAdefaultchannel())){
		out.print( "{success:false,errors:{msg:'未选择通道'}}");
		return;
		}

		if(def.indexOf("=")!=-1){
			String nestDef = def.split("=")[1];
			if(StringUtils.isBlank(nestDef)){
			out.print( "{success:false,errors:{msg:'未选择通道'}}");
			return;
			}
			//def =nestDef.replaceAll("%",",");
			smsAdmin.setAdefaultchannel(URLDecoder.decode(nestDef,"UTF-8"));
		}
		out.print(WebBusinessImpl.getInstance().updateProxy(smsAdmin));
		return;

		}catch(Exception e){
			e.printStackTrace();
			out.print( "{success:false,errors:{msg:'修改失败！！'}}");
		}
//out.print( "{success:true}");
%>
